<template>
  <div>
    <pulldown header="主动申请">
      <div slot="content">
        <z-table
          bordered
          ref="table"
          rowKey="id"
          :showAlert="false"
          :showSelection="false"
          :loading="loading"
          :columns="columns"
          :dataSource="pageData"
          @selectedRow="onSelectedRow"
          @change="onTableChange"
        >
          <template slot="action" slot-scope="text, record">
            <a @click="hrefFun(record.abortExplain)" v-if="record.abortExplain !== ''">《中止社区戒毒社区康复情况说明》</a><br>
            <a @click="hrefFun(record.continueExplain)" v-if="record.continueExplain !== ''">《继续执行社区戒毒社区康复情况说明》</a><br>
          </template>
        </z-table>
      </div>
    </pulldown>
    <pulldown header="被动申请">
      <div slot="content">
        <z-table
          bordered
          ref="table"
          rowKey="id"
          :showAlert="false"
          :showSelection="false"
          :loading="loading"
          :columns="columns1"
          :dataSource="pageData1"
          @selectedRow="onSelectedRow"
          @change="onTableChange"
        >
          <template slot="action" slot-scope="text, record">
            <a @click="hrefFun(record.abortExplain)" v-if="record.abortExplain !== ''">《中止社区戒毒社区康复情况说明》</a><br>
            <a @click="hrefFun(record.continueExplain)" v-if="record.continueExplain !== ''">《继续执行社区戒毒社区康复情况说明》</a><br>
          </template>
        </z-table>
      </div>
    </pulldown>


    <!--    {{$filterDictTextByCache('process_approval_type', 1)}}-->
  </div>
</template>

<script>
import pulldown from '../../../modules/pulldown'
import {basicDetail, Families, getAbortList, getOutLeaveList} from "@api/sjsk/archives";
export default {
  name: "basic",
  components:{ pulldown },
  mounted() {

  },
  data(){
    return   {
      resultData:{},
      innse:true,
      user:{},
      loading: false,
      columns: [
        {
          title: '序号',
          dataIndex: 'order',
          width: 60,
          align: 'center',
          customRender: (text, record, index) => {
            return `${(this.pageFilter.pageNo - 1) * this.pageFilter.pageSize + (index + 1)}` //序号分页后连续
          }
        },
        {
          title: '中止开始时间',
          dataIndex: 'abortStartDate',
          width: 60,
          align: 'center',
          customRender: text => {
            return <j-ellipsis value={text} length={14} />
          }
        },
        {
          title: '预计中止结束时间',
          dataIndex: 'abortEndDate',
          width: 110,
          align: 'left',
          customRender: text => {
            return <j-ellipsis value={text} length={20} />
          }
        },
        {
          title: '预计中止天数',
          dataIndex: 'abortDays',
          width: 80,
          align: 'center'
        },
        {
          title: '中止原由',
          dataIndex: 'abortReason',
          width: 100,
          align: 'center',
          customRender: function (text) {
            if (text == 1) {
              return "申请自愿强制隔离戒毒";
            } else if (text == 2) {
              return "其他等";
            } else {
              return text;
            }
          }
        },
        {
          title: '戒毒所',
          dataIndex: 'detoxificationCenter',
          width: 80,
          align: 'center',
          customRender: text => {
            return <j-ellipsis value={text} length={20} />
          }
        },
        {
          title: '继续执行时间',
          dataIndex: 'continueTime',
          width: 80,
          align: 'center',
          customRender: text => {
            return <j-ellipsis value={text} length={20} />
          }
        },
        {
          title: '法定原因',
          dataIndex: 'abortDays',
          width: 100,
          align: 'center',
          customRender: function (text) {
            if (text == 1) {
              return "结束自愿强制隔离戒毒";
            } else if (text == 2) {
              return "原决定机关解除刑事强制措施";
            } else if (text == 3) {
              return "人民法院判处刑罚，非收监执行";
            }  else {
              return text;
            }
          }
        },
        {
          title: '附件',
          width: 120,
          align: 'center',
          dataIndex: 'action',
          scopedSlots: { customRender: 'action' },
        }
      ],
      columns1: [
        {
          title: '序号',
          dataIndex: 'order',
          width: 60,
          align: 'center',
          customRender: (text, record, index) => {
            return `${(this.pageFilter.pageNo - 1) * this.pageFilter.pageSize + (index + 1)}` //序号分页后连续
          }
        },
        {
          title: '中止开始时间',
          dataIndex: 'abortStartDate',
          width: 60,
          align: 'center',
          customRender: text => {
            return <j-ellipsis value={text} length={14} />
          }
        },
        {
          title: '预计中止结束时间',
          dataIndex: 'abortEndDate',
          width: 110,
          align: 'left',
          customRender: text => {
            return <j-ellipsis value={text} length={20} />
          }
        },
        {
          title: '预计中止天数',
          dataIndex: 'abortDays',
          width: 80,
          align: 'center'
        },
        {
          title: '中止原由',
          dataIndex: 'abortDays',
          width: 100,
          align: 'center',
          customRender: function (text) {
            if (text == 1) {
              return "申请自愿强制隔离戒毒";
            } else if (text == 2) {
              return "其他等";
            } else {
              return text;
            }
          }
        },
        {
          title: '中止机构',
          dataIndex: 'abortOrgan',
          width: 80,
          align: 'center',
          customRender: text => {
            return <j-ellipsis value={text} length={20} />
          }
        },
        {
          title: '采取措施',
          dataIndex: 'soerciveMeasures',
          width: 80,
          align: 'center',
          customRender: function (text) {
            if (text == 1) {
              return "刑拘";
            } else if (text == 2) {
              return "逮捕";
            } else {
              return text;
            }
          }
        },
        {
          title: '继续执行时间',
          dataIndex: 'continueTime',
          width: 80,
          align: 'center',
          customRender: text => {
            return <j-ellipsis value={text} length={20} />
          }
        },
        {
          title: '法定原因',
          dataIndex: 'abortDays',
          width: 100,
          align: 'center',
          customRender: function (text) {
            if (text == 1) {
              return "结束自愿强制隔离戒毒";
            } else if (text == 2) {
              return "原决定机关解除刑事强制措施";
            } else if (text == 3) {
              return "人民法院判处刑罚，非收监执行";
            }  else {
              return text;
            }
          }
        },
        {
          title: '附件',
          width: 120,
          align: 'center',
          dataIndex: 'action',
          scopedSlots: { customRender: 'action' },
        }
      ],
      pageFilter: {
        pageNo: 1,
        pageSize: 10
      },
      pageData:[],
      pageData1:[]
    }
  },
  methods:{
    hrefFun(val){
      window.open(val)
    },
    getbasicDetail(){
      console.log(this.user)
      basicDetail({basePersonId:this.user.id,idNo:this.user.identityNumber}).then(ser => {
        if(ser.success){
          console.log(ser)
          this.resultData = ser.result
        }
      }).catch(err =>{

      })

    },
    refreshTable(id){
      this.refreshTable1('1')
      this.refreshTable2('1')
    },
    refreshTable1(id){
      getAbortList({getAbortList:1,sjskPersonId:id}).then(ser => {
        if(ser.success){
          this.pageData = ser.result
          console.log(this.pageData)
        }
      }).catch(err => {
        console.log(err)
      })
    },
    refreshTable2(id){
      getAbortList({getAbortList:2,sjskPersonId:id}).then(ser => {
        if(ser.success){
          this.pageData1 = ser.result
          console.log(this.pageData)
        }
      }).catch(err => {
        console.log(err)
      })
    },
    onSelectedRow(keys) {
      this.selectKeys = keys
      this.isDisabled = keys.length > 0 ? false : true
    },
    onTableChange(pagination, pageFilter, sorter) {
      let keyMap = { currentPage: 'pageNo' }
      let paginations = Object.keys(pagination).reduce((newData, key) => {
        let newKey = keyMap[key] || key
        newData[newKey] = pagination[key]
        return newData
      }, {})
      this.pageFilter = Object.assign({}, this.pageFilter, paginations)
      this.refreshTable()
    },
  }
}
</script>

<style scoped>

</style>